package it.asvp.asvp_portal.service.util;

import it.asvp.asvp_portal.data.entity.notification.Notification;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

@Component
public class EmailSender {

	@Autowired
	JavaMailSender mailSender;
	
	 public void sendNotification(Notification notification,String receiverEmailAddress) {
			
			    String subject = notification.getTitle();
			    String message = notification.getNote();
			
				SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
				simpleMailMessage.setTo(receiverEmailAddress);
				simpleMailMessage.setSubject(subject);
				simpleMailMessage.setText(message);
				mailSender.send(simpleMailMessage);
		
		}
	 
   public void sendEmail(String subject,String message,String receiverEmailAddress) {
		
			SimpleMailMessage simpleMailMessage = new SimpleMailMessage();
			simpleMailMessage.setTo(receiverEmailAddress);
			simpleMailMessage.setSubject(subject);
			simpleMailMessage.setText(message);
			mailSender.send(simpleMailMessage);
	
	}
}
